import request from '../../utils/request'


/**
 * 分页查询币种
 * @param currencyName
 * @param currencyCode
 * @param page
 * @returns {Promise.<Object>}
 */
export async function getCurrencyList({currencyName, currencyCode , page}) {
    return request(apiPath.basedata + "/api/currency", {
        method: 'get',
        data: { currencyName, currencyCode  , page: page.page, size: page.size}
    });
}


/**
 * 查询币种详情
 * @param id
 * @returns {Promise.<Object>}
 */
export async function getCurrencyById({id}) {
    return request(apiPath.basedata + "/api/currency/"+ id, {
        method: 'get'
    });
}

/**
 * 增加币种
 * @param currencyName
 * @param currencyCode
 * @param currencyDesc
 * @param currencyOrder
 * @param userId
 * @returns {Promise.<Object>}
 */
export async function addCurrency({currencyName, currencyCode, currencyDesc, currencyOrder,  userId}) {
    userId = 1;
    let creator = userId;
    currencyOrder = 1;
    return request(apiPath.basedata + "/api/currency", {
        method: 'post',
        data: { currencyName, currencyCode, currencyDesc, currencyOrder,  userId, creator}
    });
}


/**
 * 修改币种
 * @param id
 * @param currencyName
 * @param currencyCode
 * @param currencyDesc
 * @param currencyOrder
 * @param userId
 * @returns {Promise.<Object>}
 */
export async function updateCurrency({id, currencyName, currencyCode, currencyDesc, userId}) {
    userId = 1;
    let updater = userId;
    return request(apiPath.basedata + "/api/currency", {
        method: 'put',
        data: { id, currencyName, currencyCode, currencyDesc, userId, updater}
    });
}


/**
 * 删除币种
 * @param id
 * @returns {Promise.<Object>}
 */
export async function deleteCurrencyById({id}) {
    return request(apiPath.basedata + "/api/currency/" + id , {
        method: 'delete'
    });
}


/**
 * 获取所有币种信息
 *
 * @returns {Promise.<void>}
 */
export async function getAllCurrencys() {
    return request(apiPath.basedata + "/api/allCurrency", {
        method: 'get'
    });
}